home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / newmk.zip / INC / SHRMEM.H < prev   
Text File  |  1992-09-01  |  4KB  |  123 lines

  1. /************************************************************************\
  2. * The enclosed files, "the software," is provided by 
  3. * Microsoft Corporation "as is" without warranty of any kind. 
  4. * MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, 
  5. * INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY 
  6. * AND FITNESS FOR A PARTICULAR PURPOSE.  You assume all risks of 
  7. * using the software.
  8. * The software is Copyright (c) 1992 Microsoft Corporation.
  9. * Original Author: John M. Hall, Microsoft SDE  9/1/92
  10. *
  11. * You are granted the right to freely distribute this software.
  12. * You are granted the right to make changes provided this comment block
  13. * is retained without modification and you acknowledge the changes.
  14. \************************************************************************/
  15. /************************************************************************\
  16. *
  17. *                               SHRMEM.H
  18. *
  19. \************************************************************************/
  20.  
  21. #ifndef SHRMEM_DLL_H
  22. #define SHRMEM_DLL_H
  23.  
  24. /************************************************************************\
  25. *                         SYMBOLIC CONSTANTS
  26. \************************************************************************/
  27.  
  28. #define FREE        0x00
  29. #define EXCLUSIVE   0x01
  30. #define SHARED      0x02
  31. #define HEAD        0xF0
  32.  
  33. #ifdef SHRMEM_DLL_C
  34. #define ALLFFS      0xFFFFFFFF
  35. #define SZ_MEMORY   (1024 * 1024)
  36. #define SZ_CONTROL  (1024 * 64)
  37. #define NUMBER_ELEM 256
  38. #define MUNGE       37
  39.  
  40. /************************************************************************\
  41. *                          GLOBAL SHARED VARIABLES
  42. \************************************************************************/
  43.  
  44. DWORD dwPageSize;
  45. DWORD dwProcesses;
  46. int   iiUnused;
  47. LPVOID lpTryBase;
  48. DWORD dwBase;
  49. DWORD dwLength;
  50.  
  51. /************************************************************************\
  52. *                          GLOBAL NON-Shared VARIABLES
  53. \************************************************************************/
  54.  
  55. HANDLE hMod = NULL;
  56. HANDLE hSemaphore = NULL;
  57. HANDLE hMemory = NULL;
  58. LPVOID lpMemBase = NULL;
  59. HANDLE hControl = NULL;
  60. LPVOID lpCtrlBase = NULL;
  61. DWORD  dwProcessID = 0;
  62. FILE *fp_log = NULL;
  63.  
  64. /************************************************************************\
  65. *                          MACROS
  66. \************************************************************************/
  67. #define MAKE_PTR(a,b)  ((LPVOID)((DWORD)(a) + (b)))
  68. #define MUNGEIT(a) ( ((a)+1)* MUNGE)
  69. #define UNMUNGE(a) ( ((a)/MUNGE)-1)
  70.  
  71. // turn the wOffset (in pages) into a LPVOID
  72. #define MAKE_LPV(a) ((LPVOID) ((DWORD)lpMemBase + (dwPageSize * (a))))
  73.  
  74.  
  75. #ifdef DEBUG
  76. #define AssertBox(a,b) if (!(a)) MyAssertBox((b), #a, __FILE__, __LINE__)
  77. #else
  78. #define AssertBox(a,b)
  79. #endif
  80.  
  81. /************************************************************************\
  82. *                          STRUCTURES
  83. \************************************************************************/
  84.  
  85. typedef struct {
  86.     DWORD dwProcessID;
  87.     WORD  wOffset;
  88.     WORD  wLength;
  89.     SHORT sNext;
  90.     SHORT sPrior;
  91.     ATOM  aName;
  92.     UCHAR uchLock;
  93.     UCHAR uchFlags;
  94. } FREE_ELEMENT;
  95. typedef FREE_ELEMENT *FEP;
  96. #endif
  97.  
  98. /************************************************************************\
  99. *                         FLAGS
  100. \************************************************************************/
  101. #define SHR_MEM_FREE    0x00
  102. #define SHR_MEM_ALLOC   0x01
  103. #define SHR_MEM_INVALID 0x02
  104.  
  105. /************************************************************************\
  106. *                         FUNCTION PROTOTYPES
  107. \************************************************************************/
  108. VOID    MyAssertBox( const char *, const char *, const char *, int);
  109.  
  110. DWORD   ShrAlloc(DWORD dwSize, UCHAR uchFlags);
  111. LPVOID  ShrLock( DWORD hShr);
  112. DWORD   ShrUnlock( DWORD hShr);
  113. DWORD   ShrFree( DWORD hShr);
  114. BOOL    DLLEntryPoint (HANDLE hDLL, DWORD dwReason, LPVOID lpReserved);
  115. BOOL    attach_memory(LPTSTR lptstr);
  116. BOOL    ShrName(DWORD hShr, LPCTSTR lpsz);
  117. DWORD   ShrGet(LPCTSTR lpsz);
  118. VOID    ShrDump(void);
  119.  
  120. #endif // SHRMEM_DLL_H
  121.